home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / packet / p_aa4re / bb212src / bbsrtgar.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1991-06-29  |  3.6 KB  |  110 lines

  1. (*===========================================================================*)
  2. (* Procedure to receive random strings from tnc                              *)
  3. (*                                                                           *)
  4. (*   Copyright 1988, 1991 by H. Roy Engehausen.  All rights reserved.        *)
  5. (*   This software may be freely distributed and used, but it may not        *)
  6. (*   under any circumstances be sold by anyone other than the author.        *)
  7. (*   It may be distributed by a commercial company as long as it is          *)
  8. (*   for no cost.                                                            *)
  9. (*                                                                           *)
  10. (*===========================================================================*)
  11.  
  12. FUNCTION garbage_collect_tnc : STRING;
  13.  
  14.   VAR
  15.     i              : BYTE;
  16.     int_no         : BYTE;
  17.     tnc_registers  : REGISTERS;
  18.     result         : STRING;
  19.  
  20.   BEGIN;
  21.  
  22.     WITH active_port^, tnc_registers DO
  23.  
  24.       BEGIN;
  25.  
  26.         (*-------------------------------------------------------------------*)
  27.         (* No garbage on these TNCs                                          *)
  28.         (*-------------------------------------------------------------------*)
  29.  
  30.         IF (port_type = port_pc1xx) OR (port_type = port_bpqhost) THEN
  31.           BEGIN;
  32.             garbage_collect_tnc := '';
  33.             EXIT;
  34.           END;
  35.  
  36.         (*-------------------------------------------------------------------*)
  37.         (* Get ready for loop                                                *)
  38.         (*-------------------------------------------------------------------*)
  39.  
  40.         i := 0;
  41.         int_no := active_port^.com_number;
  42.  
  43.         (*-------------------------------------------------------------------*)
  44.         (* Perform the initial RECEIVE DATA AVAILABLE test. Assumed true     *)
  45.         (* for the PC*PA adapter                                             *)
  46.         (*-------------------------------------------------------------------*)
  47.  
  48.         IF (port_type <> port_pcpa) THEN
  49.           BEGIN;
  50.             AX := $0300;
  51.             DX := com_number - 1;
  52.  
  53.             INTR(tnc_interrupt, tnc_registers);
  54.  
  55.             AH := AH AND lsr_8250_dr;
  56.           END
  57.         ELSE
  58.           AH := 1;
  59.  
  60.         (*-------------------------------------------------------------------*)
  61.         (* Loop while data is available and the data count is acceptable     *)
  62.         (*-------------------------------------------------------------------*)
  63.  
  64.         WHILE (AH <> 0) AND (i < 128) DO
  65.           BEGIN;
  66.  
  67.             i := i + 1;
  68.  
  69.             IF port_type <> port_pcpa THEN
  70.               BEGIN;
  71.                 AX := $0200;
  72.                 DX := com_number - 1;
  73.  
  74.                 INTR(tnc_interrupt, tnc_registers);
  75.               END
  76.             ELSE
  77.               BEGIN;
  78.  
  79.                 AX := 0;
  80.                 INTR(int_no, tnc_registers);
  81.  
  82.               END;
  83.  
  84.             {$IFDEF wa8debug}
  85.               WRITE('.',CHR(AL), AL);
  86.             {$ENDIF}
  87.  
  88.             result[i] := CHR(AL);
  89.  
  90.  
  91.             IF port_type <> port_pcpa THEN
  92.               AH := AH AND lsr_8250_dr
  93.             ELSE
  94.               IF AH = 0 THEN
  95.                 DEC(i);
  96.  
  97.           END;
  98.  
  99.         (*-------------------------------------------------------------------*)
  100.         (* Set the result and exit                                           *)
  101.         (*-------------------------------------------------------------------*)
  102.  
  103.         result[0] := CHR(i);
  104.  
  105.         garbage_collect_tnc := result;
  106.  
  107.       END;
  108.  
  109.   END;
  110.